package com.parsifal;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 * Created by yangming on 17-2-14.
 */
public class FileUtil {

    private FileUtil() {
    }

    private static class SingletonHolder {
        private final static FileUtil INSTANCE = new FileUtil();
    }

    public static FileUtil getInstance() {
        return FileUtil.SingletonHolder.INSTANCE;
    }

    public void save(String path, String string, String encode) {
        try {
            OutputStreamWriter out = new OutputStreamWriter(
                    new FileOutputStream(path), encode);
            out.write(string);
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
